﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace RakutenCrawler.Repository
{
    public class ProcessTrackingRepository:GenericRepository<ProcessTracking>
    {
        public override void InsertOrUpdate(ProcessTracking item)
        {
            var check = Single(p => p.LinkConfigGuid == item.LinkConfigGuid || p.ProcessTrackingId == item.ProcessTrackingId);
            if (check == null)
            {
                item.CrawlStatus = Constants.NotWorkingStatus;
                All.AddObject(item);
            }
            else
            {
                if (item.ProcessTrackingId == 0)
                    item.ProcessTrackingId = check.ProcessTrackingId;
                All.ApplyCurrentValues(item);
            }
        }
    }
}
